package main

func twoSum(nums []int, target int) []int {
	size := len(nums)
	m := make(map[int]int) // number -> index
	for i, v := range nums {
		m[v] = i
	}
	for i := 0; i < size; i++ {
		val := nums[i]
		j, ok := m[target-val]
		if ok && i != j {
			return []int{i, j}
		}
	}
	return nil
}
